package quq.missq.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.ArrayList;
import quq.missq.R;
import quq.missq.beans.School;

/**
 * Created by River on 8/6/15.
 */
public class SchoolAdapter extends BaseAdapter{

    private ArrayList<School> schooles;
    private Context mContext;

    public SchoolAdapter(Context context){
        this.mContext = context;
    }

    public void setData(ArrayList<School> schooles){
        this.schooles = schooles;
    }

    public ArrayList<School> getData(){
        return schooles;
    }

    @Override
    public int getCount() {
        return schooles.size();
    }

    @Override
    public Object getItem(int position) {
        return schooles.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Holder holder;
        if(null == convertView){
            holder = new Holder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.school_adapter,null);
            holder.name = (TextView)convertView.findViewById(R.id.universityName);
            convertView.setTag(holder);
        }else{
            holder = (Holder)convertView.getTag();
        }
        holder.name.setText(schooles.get(position).getM_nUniversity_Name());
        return convertView;
    }

    private class Holder{
        TextView name;
    }

}
